<template>
    <div>
        用户个人信息
        <el-card class="box-card" style="margin-top:15px;">
                <el-form  label-width="80px">
                    <el-form-item label="账号">
                        <div>{{this.tableData.username}}</div>
                    </el-form-item>
                    <el-form-item  label="头像" >
                        <el-input v-model="tableData.img"  placeholder="请输入图片网络链接" ></el-input>
                    </el-form-item>
                    <el-form-item  label="账户昵称" >
                        <el-input v-model="tableData.nickname"  ></el-input>
                    </el-form-item>
                    <el-form-item    label="现密码">
                        <el-input  type = 'password' v-model="oldpassword"  ></el-input>
                    </el-form-item>
                    <el-form-item    label="重置密码">
                        <el-input   v-model="password"  ></el-input>
                    </el-form-item>
                    <el-form-item  label="店铺简介" >
                        <el-input v-model="tableData.brief"  ></el-input>
                    </el-form-item>
                    <el-form-item  label="联系电话" >
                        <el-input v-model="tableData.telephone"  ></el-input>
                    </el-form-item>
                    <el-form-item  label="地址" >
                        <el-input v-model="tableData.addr"  ></el-input>
                    </el-form-item>
                </el-form>
                    <el-button type="primary" @click="editSave">提交修改消息</el-button>
        </el-card>

    </div>
</template>

<script>
export default {
    name: "PerCenter",
    data() {
        return {
            param:{
                userid:window.sessionStorage.getItem('userid'),

            },
            //表格数据
            tableData: {
              age:"",
            },
            Editform:{

            },
            oldpassword:"",
            password:"",
        }
    },
    methods: {
        getList(){  ////查询功能，当前有哪些
          this.param.role = 2;
            this.$ajax.get(this.$API.http+"api/User/info", {params:this.param}).then(res=> {
                    this.msg = res.data.msg;
                    if(res.data.code == 1){
                        this.tableData = res.data.data;
                        console.log(this.tableData);
                        this.total = res.data.total;
                        console.log(this.total);
                    }else{
                        this.$msg.error(this.msg);
                    }
                },
                error => {
                    //请求后更新List的数据
                    window.alert(error);
                }
            )
        },
        get_edit_data(){
            this.Editform= this.tableData;
            this.Editform.oldpassword = this.oldpassword;
            this.Editform.password = this.password;
            console.log(this.Editform);
        }
        ,
        editSave(){
            this.get_edit_data();
            this.Editform.role = 2;
            this.$ajax.get(this.$API.http+"api/User/updateuser", {params:this.Editform}).then(res=> {
                    this.msg = res.data.msg;
                    if(res.data.code == 1){
                        this.tableData = res.data.data;
                      this.$msg.success(this.msg);
                        // console.log(this.tableData);
                    }else{
                        this.$msg.error(this.msg);
                    }
                },
                error => {
                    //请求后更新List的数据
                    window.alert(error);
                }
            )
        }
    }
    ,
    created() {
        this.getList();
    },
}
</script>

<style scoped>


</style>

